﻿using UnityEngine;

/// <summary>
/// 火元素与燃烧元素
/// </summary>
public class GeneralIceAura : IGeneralElementAura
{
    private readonly IElementHolder _holder;
    private readonly IElementAura _iceAura;
    private readonly IElementAura _freezeAura;

    public GeneralIceAura(IElementHolder holder)
    {
        _holder = holder;
        _iceAura = _holder.GetElementAura("冰");
        _freezeAura = _holder.GetElementAura("冻结");
    }

    public float Gauge => Mathf.Max(_iceAura.Gauge, _freezeAura.Gauge);

    public void UseGauge(float cost)
    {
        var iceGauge = _iceAura.Gauge;
        if (cost > iceGauge)
        {
            var freezeCost = cost - iceGauge;
            _iceAura.Gauge -= cost;
            _freezeAura.Gauge -= freezeCost;
        }
        else
        {
            _iceAura.Gauge -= cost;
        }
    }
}